package com.example.myproject

import android.os.Bundle
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.ComponentActivity
import androidx.activity.enableEdgeToEdge
import androidx.compose.material3.Text
import androidx.compose.ui.graphics.Color


class MainActivity : ComponentActivity() {

    val expert = MyProject()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)

        val spinner = findViewById<Spinner>(R.id.spinner)
        val button = findViewById<Button>(R.id.button)
        val textView = findViewById<TextView>(R.id.textView)

//        button.setOnClickListener {
//            val selectedFeature = spinner.selectedItem.toString()
//              textView.text = selectedFeature
//        }
        button.setOnClickListener {
            textView.text = expert.getLanguage(feature = spinner.selectedItem.toString())
        }

        val dynamicTexts: LinearLayout = findViewById(R.id.dynamic_texts)
        val buttonAddText: Button = findViewById(R.id.button2)

        buttonAddText.setOnClickListener {
            val count = dynamicTexts.childCount + 1
            val dynamicText = TextView(this).apply {
                text = "This is a new TextView: $count\n"
                textSize = 16f
//                setTextColor(Color.RED)
//                setBackgroundColor(Color.BLUE)
                setPadding(16, 12, 16, 12)
            }
            dynamicTexts.addView(dynamicText)
        }

    }
}